package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.IConfigApp;
import com.itboye.mengwu.data.model.AppConfigModel;
import com.itboye.mengwu.data.model.VIPPersonalBean;

public class ConfigAppRepository extends BaseNetRepository implements
		IConfigApp<AppConfigModel> {

	public static final String ConfigApp = "BY_Config_app";
	public static final String Guanzhu = "BY_BbsUserCenter_getUserInfo";

	public ConfigAppRepository(ICompleteListener listener) {
		super(listener);
	}

	@Override
	public void add(AppConfigModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(AppConfigModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(AppConfigModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(AppConfigModel model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<AppConfigModel>() {
		}.getType();
		String apiVer = "102";
		Map<String, Object> params = new HashMap<String, Object>();
		// params.put("id", model.getId());
		(new Builder<AppConfigModel>())
				.setTypeVerParamsAndReturnClass(ConfigApp, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<AppConfigModel>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public List<AppConfigModel> query(AppConfigModel model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getGuanZhu(String uid,String fromUid) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<VIPPersonalBean>() {
		}.getType();
		String apiVer = "101";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		if(fromUid!=null)
			params.put("from_uid", fromUid);
		(new Builder<VIPPersonalBean>())
				.setTypeVerParamsAndReturnClass(Guanzhu, apiVer, params, type)
				.requestListener(
						new BaseSuccessReqListener<VIPPersonalBean>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

}
